import api from "../share/api.js";
import "./base.css";
import { useEffect, useState } from "react";
const modules = ["persons", "info", "logout"];
const modules_auth = [2, 1, 1];

function Settings() {
  const [renders, set_renders] = useState(["loading settings"]);

  const getData = async () => {
    let res = await api.getPersonList("textInput100,textInput101,select104");
    console.log(res.data);
    if (res.ok) {
      return res.data;
    }
    return "failed get data.";
  };

  useEffect(() => {
    getData().then((data) => {
      data.unshift({
        name: "name",
        account: "account",
        identity: "role",
      });

      let userList = data.map((d) => (
        <div key={d.name} className="list-row">
          <div>{d.name}</div>
          <div>{d.account}</div>
          <div>{d.identity}</div>
        </div>
      ));
      set_renders(userList);
    });
  }, []); // 设置空的依赖数组，只在组件挂载时运行一次

  return <div className="list-col">{renders}</div>;
}
export default Settings;
